<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>订单展示页</title>
	<script src='__PUBLIC__/Js/jquery.js'></script>
	<script src="//cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.js"></script>
	<link href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet">
	<script src="__PUBLIC__/Js/Jqui/jquery-ui.min.js"></script>
	<script src="__PUBLIC__/Js/jqPaginator.js"></script>
	<style>
	*{margin:0;padding:0;}
	a{cursor:pointer;}
	.obody{width:1000px;margin:100px auto;}
	.pagediv{margin:-100px auto;width:600px;}
	</style>
</head>
<body>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~固定在头部的导航栏~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
		<div class="navbar-header">
			 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button> <a class="navbar-brand">订单展示</a>
		</div>
		<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
			<ul class="nav navbar-nav">
				<li class="active">
					 <a>|</a>
				</li>						
			</ul>
			<form action="<{:U('Admin/Order/index')}>" id='sfrm' method='post'  class="navbar-form navbar-left" role="search">
				<div class="form-group">
					<input type="text" id="stxt" class="form-control" name="search" placeholder="订单号查询" />
					<input type="hidden" class="shid" value='<{$sear}>'>
				</div> <input type="button" id="sbtn" class="btn btn-default" value="查询">
			</form>
		</div>
	</nav>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~展示的表格~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<div class="obody"><table id="showtable" class="table table-hover"></table></div>
<div class="pagediv"><ul id="page" class="pagination"></ul></div>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~js代码部分~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<script>
$(function(){
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function getLocalTime(nS) { 
    return new Date(parseInt(nS) * 1000).toLocaleString().substr(0,17);
}

//无刷分页~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	$('#page').jqPaginator({
          totalPages: <{$show}>,
          visiblePages: 3,
          currentPage: 1,
          first: '<li class="prev"><a href="javascript:;">首页</a></li>',
          prev: '<li class="prev"><a href="javascript:;">上一页</a></li>',
            next: '<li class="next"><a href="javascript:;">下一页</a></li>',
            last: '<li class="next"><a href="javascript:;">尾页</a></li>',
            page: '<li class="page"><a href="javascript:;">{{page}}</a></li>',
          onPageChange: function (num,type) {
          	var sear = $('.shid').val();
          	console.log(sear);
			var html="<thead><tr><th>"+'订单号'+"</th><th>"+'会员账号'+"</th><th>"+'收货人'+"</th><th>"+'收货电话'+"</th><th>"+'收货地址'+"</th><th>"+'下单时间'+"</th><th>"+'订单状态'+"</th><th>"+'操作'+"</th></tr></thead>";			
	          $.get("<{:U('Admin/Order/doindex')}>",{p:num,sear:sear},function(data){
	          	$(data).map(function(k,v){
	          		html+="<tr class='showorder' id='order_"+v.oid+"'><td>"+v.ordnum+"</td><td>"+v.user_name+"</td><td>"+v.ord_name+"</td><td>"+v.ord_tel+"</td><td>"+v.ord_addr+"</td><td>"+getLocalTime(v.ordtime)+"</td><td>"+v.effect+"</td><td><a class='ordermore' href='<{:U('Admin/Order/more')}>?oid="+v.oid+"' id='"+v.oid+"_order' >"+'查看'+"</a></td><input type='hidden' class='effects' data-types="+v.effect+"></tr>";          
	              });
	          	$('#showtable').html(html); 
	          	$('.effects[data-types=0]').prev().prev().html("<font color='gray'>已取消</font>");
	          	$('.effects[data-types=1]').prev().prev().html('未付款');
	          	$('.effects[data-types=2]').prev().prev().html("<font color='red'>待发货</font>");
	          	$('.effects[data-types=3]').prev().prev().html("<font color='yellow'>已发货</font>");
	          	$('.effects[data-types=4]').prev().prev().html("<font color='green'>已收货</font>");
	            
	          },'json');
         }   
      })
//搜索
$(document).on('click','#sbtn',function(){
	var sss = $('#stxt').val();
	$('#sfrm').submit();
})
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
});
</script>
</body>
</html>